package com.ruoyi.walmart.mapper.shipments;

import com.ruoyi.walmart.domain.shipments.Shipment;
import com.ruoyi.walmart.domain.shipments.ShipmentItem;
import com.ruoyi.walmart.dto.ShipmentItemDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface ShipmentMapper {

    /**
     * 查询
     * @return 结果
     */
    List<Shipment> selectShipmentByAuthId(@Param("authId") Long authId);

    /**
     * 批量添加
     * @param shipmentList
     * @return
     */
    int shipmentInsertList(List<Shipment> shipmentList);

    /**
     * 全部
     * @return
     */
    int deleteShipmentByAuthId(@Param("authId") Long authId);

    /**
     * 条件查询
     * @param shipment
     * @return
     */
    List<Shipment> selectList(Shipment shipment);

    /**
     * 查询状态
     * @param shipment 条件
     * @return 结果
     */
    int countByStatus(Shipment shipment);

    /**
     * 修改状态
     * @param shipment
     * @return
     */
    int updateStatus(Shipment shipment);
    /**
     * 查询货件信息
     * @param shipment
     * @return
     */
    Shipment selectShipment(Shipment shipment);
    /**
     * 更新主表货运数量
     * @param shipmentItem
     * @return
     */
    int updatedShipmentUnits(ShipmentItem shipmentItem);
    /**
     *  更新主表状态为CREATED,模仿店铺后台的状态
     * @param shipment
     * @return
     */
    int updatedShipmentStatus(Shipment shipment);
    /**
     *  删除货运主表
     * @param shipmentId
     * @return
     */
    int deleteByShipmentId(String shipmentId);
    /**
     * 查询已取消状态的 shipment_id 列表
     * @param shipmentIds
     * @return
     */
    List<String> selectCancelledShipmentIds(@Param("shipmentIds") List<String> shipmentIds);
    /**
     * 查询是否已有货件任务
     */
    Integer checkExistenceShipments(Long authId);
    /**
     * 查询货件最大时间往前推两个月
     */
    LocalDateTime delayShipmentsDate(Long authId);
    // 根据shipmentId列表删除Shipment
    void deleteShipmentsByIds(@Param("shipmentIds") List<String> shipmentIds);
}
